<template>
	<view>
		<cu-custom bgColor="bg-red" :isBack="true"><block slot="backText">返回</block><block slot="content">详情</block></cu-custom>
		<view v-for="(item,index) in info.list" :key="index" class="cu-form-group">
			<view class="title">{{item.name}}</view>
			<text class="text-grey">{{item.value}}</text>
		</view>
		<view class="cu-tabbar-height margin-bottom-sm"></view>
		<view class="cu-bar bg-white tabbar shadow border" style="position: fixed;bottom: 0;width: 100%;">
			<view class="bg-green submit" @tap="update(info.id)">编辑</view>
			<view class="bg-red submit" @tap="deleteHandle(info.id)">删除</view>
		</view>
	</view>
</template>

<script>
	import * as $http from '@/api/list.js'
	export default {
		data() {
			return {
				info:null
			};
		},
		onLoad(options) {
			this.infoHandle(options.id)//获取详情
		},
		methods: {
			infoHandle(id){//获取详情
				let _this = this
				// $http.getInfo(id).then( res => {
				// 	if(res.code == 0){
				// 		this.info = res.data
						this.info = {
							id:"1123323333",
							list:[{name:'名称',value:'值'},
							{name:'名称',value:'值'},
							{name:'名称',value:'值'},
							{name:'名称',value:'值'},
							{name:'名称',value:'值'},
							{name:'名称',value:'值'},
							{name:'名称',value:'值'},
							{name:'名称',value:'值'}]
						}
							
						
				// 	}
				// }).catch( err => {});
			},
			update(id){//编辑
				uni.navigateTo({
					url: "./add-or-update?id="+id
				})
			},
			deleteHandle(id){//删除
				uni.showModal({
					title: '提示',
					content: '确定删除么？',
					success: function (res) {
						if (res.confirm) {
							$http.getDelete([id]).then( res => {
								if(res.code == 0){
									uni.showToast({
										title: '删除成功',
										icon:"success"
									});
									setTimeout(function () {
										uni.reLaunch({
											url: "./index"
										})
									}, 2000);
								}
							}).catch( err => {});
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>

<style lang="less">
	.tag-title{
		position: relative;
		overflow: hidden;
		.tag{
			width: 200upx;
			height: 100upx;
			position: absolute;
			right: -80upx;
			top: -30upx;
			transform: rotate(45deg);
			text-align: center;
			line-height: 150upx;
		}
	}
</style>
